import type { RouteRecordRaw } from 'vue-router';
import { BankOutlined } from '@ant-design/icons-vue';
// import { orderBy } from 'lodash-es';
// interface ImList {
//   pathJson: string;
//   name: string;
//   meta: Imeta;
// }
// const pages = import.meta.glob('@/views/admin/**/page.ts', {
//   eager: true,
//   import: 'default'
// });
// const pageComp = import.meta.glob('@/views/admin/**/index.vue');
// const metaList: ImList[] = Object.entries(pages).map(([path, meta]) => {
//   const pathJson = path;
//   const name = path.split('/')[path.split('/').length - 2];
//   return {
//     pathJson,
//     name,
//     meta: meta as Imeta
//   };
// });

// function getRouters(): Array<RouteRecordRaw> {
//   const oneMenus = metaList.filter((item) => !item.meta.parentKey);
//   return meatListToRoutes(oneMenus);
// }
// function meatListToRoutes(oneMenus: Array<any>): Array<RouteRecordRaw> {
//   const routes = [];
//   const sortMenus = orderBy(oneMenus, ['meta.meunOrder']);
//   for (const pItem of sortMenus) {
//     const { pathJson, name, meta } = pItem;
//     const pathComp = pathJson.replace('page.ts', 'index.vue');
//     let obj = {};
//     if (pageComp[pathComp]) {
//       obj = {
//         path: name,
//         name,
//         meta,
//         component: pageComp[pathComp]
//       };
//     } else {
//       const childrenList = metaList.filter((item) => item.meta.parentKey === meta.key);
//       const childrenMenu = meatListToRoutes(childrenList);
//       obj = {
//         path: name,
//         name,
//         meta,
//         children: childrenMenu,
//         redirect: {
//           name: childrenMenu[0]?.name
//         }
//       };
//     }
//     routes.push(obj);
//   }
//   return routes as Array<RouteRecordRaw>;
// }

const examRoutes: Array<RouteRecordRaw> = [
  {
    path: '/admin',
    name: 'admin',
    meta: {
      title: 'admin'
    },
    component: () => import('@/views/admin/index.vue'),
    redirect: { name: 'hosp' },
    children: [
      {
        path: 'hosp',
        name: 'hosp',
        meta: {
          title: '医院管理',
          icon: BankOutlined
        },
        component: () => import('@/views/admin/hosp_admin/index.vue'),
      },
      {
        path: 'device',
        name: 'device',
        meta: {
          title: '设备管理',
          icon: BankOutlined
        },
        component: () => import('@/views/admin/device_admin/index.vue'),
      },
      {
        path: 'user',
        name: 'user',
        meta: {
          title: '用户管理',
          icon: BankOutlined
        },
        component: () => import('@/views/admin/user_admin/index.vue'),
      },
      {
        path: 'doctor',
        name: 'doctor',
        meta: {
          title: '医师管理',
          icon: BankOutlined
        },
        component: () => import('@/views/admin/doctor_admin/index.vue'),
      },
      {
        path: 'valid',
        name: 'valid',
        meta: {
          title: '校验管理',
          icon: BankOutlined,
          group: true
        },
        redirect: { name: 'baseInfo' },
        children: [
          {
            path: 'baseInfo',
            name: 'baseInfo',
            meta: {
              title: '基本信息校验',
              icon: ''
            },
            component: () => import('@/views/admin/valid_admin/base_info/index.vue'),
          },
          {
            path: 'sensitiveWord',
            name: 'sensitiveWord',
            meta: {
              title: '敏感词汇校验',
              icon: ''
            },
            component: () => import('@/views/admin/valid_admin/sensitive_word/index.vue'),
          },
          {
            path: 'mutualExclusion',
            name: 'mutualExclusion',
            meta: {
              title: '内容互斥校验',
              icon: ''
            },
            component: () => import('@/views/admin/valid_admin/mutual_exclusion/index.vue'),
          },
          {
            path: 'sectionValue',
            name: 'sectionValue',
            meta: {
              title: '段落值校验',
              icon: ''
            },
            component: () => import('@/views/admin/valid_admin/section_value/index.vue'),
          },
          {
            path: 'sectionFormat',
            name: 'sectionFormat',
            meta: {
              title: '段落格式校验',
              icon: ''
            },
            component: () => import('@/views/admin/valid_admin/section_format/index.vue'),
          },
        ]

      },
      {
        path: 'slice',
        name: 'slice',
        meta: {
          title: '切面管理',
          icon: BankOutlined,
          group: true
        },
        redirect: { name: 'imagePart' },
        children: [
          {
            path: 'imagePart',
            name: 'imagePart',
            meta: {
              title: 'AI图像部位',
              icon: ''
            },
            component: () => import('@/views/admin/slice_admin/img_part/index.vue'),
          },
          {
            path: 'imageMap',
            name: 'imageMap',
            meta: {
              title: '切面关联部位',
              icon: ''
            },
            component: () => import('@/views/admin/slice_admin/img_map/index.vue'),
          }
        ]

      }

    ]
  }
];

export default examRoutes;
